#include<iostream>
#include<stack>
using namespace std;
int main()
{
	stack <int> s;
	int i=0;
	string m1[8]={ "/*" , "(" , "[" , "{" , "}" , "]" , ")" , "*/" };
	char m2[8] = { ' ' ,  '(' , '[' , '{' , '}' , ']' , ')' , ' ' } ;
	char str[1000];
	while(gets(str)){
		if(str[0]=='.')
		break;
		for(i=0;str[i];i++){
			int index= -1;
			if(str[i] == '/'){
				if(str[i+1] == '*'){
					index=0;
					i++;
				}
			}
			else if(str[i] == '*'){
				if(str[i+1] == '/'){
					index= 7;
					i++;
				}
			}
			else
			 for(int j=1;j<=6;j++){
			 	if(str[i]==m2[j]){
			 		index = j;
			 		break;
				 }
			 }
			 if(index == -1) continue;
			 else if(index <4) s.push(index);
			 else{
			 	if(s.size() == 0){
			 	 cout<<"NO"<<endl<<"?-"<<m1[index]<<endl;
			 	 return 0;}
			 	if(s.top()+index != 7){
			 		cout<<"NO"<<endl;
			 		int pre = s.top();
			 		s.pop();
				if( s.top()+index != 7 ){	
						if( index <= 3 )
							cout << m1[s.top()] << "-?" << endl ;
						else
							cout << "?-" << m1[s.top()] << endl ;
				}
				else{
						if( pre <= 3 ) 
							cout << m1[ pre ] << "-?" << endl ;
						else
							cout << "?-" << m1[ pre ] << endl ;
					}
					return 0;
				}
				else
				 s.pop();
			 }
		}
	}
	if( !s.empty() ){
		cout << "NO" << endl ;
		while( s.size()!=1 )
			s.pop();
		cout << m1[s.top()] << "-?" << endl ;
		
		return 0;
	}	
	cout << "YES" << endl ;
	return 0 ;
}
